package solution61;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] strs = sc.nextLine().split(" ");

        int N = strs.length;
        ListNode dummy = new ListNode(0);
        ListNode head = dummy;
        for (String str : strs) {
            dummy.next = new ListNode(Integer.parseInt(str));
            dummy = dummy.next;
        }
        head = head.next;
//        ListNode temp = head;
//        while (temp != null) {
//            System.out.print(temp.val+" ");
//            temp = temp.next;
//        }
        int n = sc.nextInt();
        Solution solution = new Solution();
        ListNode ans = new ListNode(0);
        ans.next = solution.rotateRight(head,n);
        while (ans.next != null) {
            ans = ans.next;
            System.out.print(ans.val+" ");
        }
    }
}
